Way back in r8196, a test was added to assert that Setup.php is being
included at file scope.[1] That test was broken when I633a6ff23 moved the
inclusion of DefaultSettings.php into Setup.php itself.
This fixes the test by having it directly set a variable and see if that
variable is a global. Yes, there's several ways to bypass it, but we're
just trying to avoid accidents here rather than trying to be foolproof.
[1]: Or really, in the same scope as DefaultSettings.php. But it
intended to be checking for file scope.
Change-Id: I9b5f15bf01c2903e8d44d85c54465d90c047cb51
exit( 1 );
}
+// Check to see if we are at the file scope
+$wgScopeTest = 'MediaWiki Setup.php scope test';
+if ( !isset( $GLOBALS['wgScopeTest'] ) || $GLOBALS['wgScopeTest'] !== $wgScopeTest ) {
+ echo "Error, Setup.php must be included from the file scope.\n";
+ die( 1 );
+}
+unset( $wgScopeTest );
+
/**
* Pre-config setup: Before loading LocalSettings.php
*/
// Don't let any other extensions load
ExtensionRegistry::getInstance()->finish();
-// Check to see if we are at the file scope
-if ( !isset( $wgVersion ) ) {
- echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
- die( 1 );
-}
-
mb_internal_encoding( 'UTF-8' );
// Set the configured locale on all requests for consisteny